package com.wondersgroup.fjzlpt.org.dao.impl.ksxx;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.quick.framework.boot.repository.sql.bean.SQLBean;
import com.quick.framework.boot.repository.sql.bean.page.PageQuerySQLBean;
import com.quick.framework.boot.repository.sql.bean.table.TableBean;
import com.quick.framework.boot.repository.sql.jdbcTemplate.impl.BaseJTDAOImpl;
import com.quick.framework.boot.repository.sql.jdbcTemplate.rs.ResultHandlerConstant;
import com.wondersgroup.fjzlpt.org.dao.inter.ksxx.KsxxDAO;

@Repository
public class KsxxDAOImpl extends BaseJTDAOImpl implements KsxxDAO{

	@Override
	@Autowired
	@Qualifier("TB_ZD_KSXX")
	public void setTb(TableBean tb) {
		super.setTb(tb);
	}
	
	
	@Override
	public JSONObject queryPage(Map<String, String> map) {
		StringBuffer sbuf = new StringBuffer();
		sbuf.append("select * from " + this.tb.getTableName() + " where 1=1 ");
		List list = new ArrayList();
		String value = map.get("PTJGID");
		if(!StringUtils.isEmpty(value))
		{
			sbuf.append("and PTJGID = ?");
			list.add(value);
		}
		PageQuerySQLBean sb = checkAndCreatePageQuerySQLBean(map, sbuf.toString(), "order by KSDM", list.toArray());
		return super.queryPage(sb, ResultHandlerConstant.JSONARRAY);
	}

	/**
	 * 查询所有科室信息
	 * @param map
	 * @return
	 */
	public JSONArray queryAll(Map<String, String> map){
		StringBuffer sqlBuf = new StringBuffer("select * from ").append(this.tb.getTableName());
		
		SQLBean bean = new SQLBean(sqlBuf.toString());
		
		return super.queryList(bean);
	}
	
	
}
